/**
 * This file is part of Lineage II Client Data Parser.
 * 
 * Lineage II Client Data Parser is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * Lineage II Client Data Parser is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with Lineage II Client Data Parser.  If not, see <http://www.gnu.org/licenses/>.
 */
package net.l2emuproject.entity;

import net.l2emuproject.entity.base.DefaultEntity;

/**
 * @author Savormix
 *
 */
public final class ClanBase extends DefaultEntity
{
	private final int		element;
	private final int		tag;
	private final int		id;
	private final String	name;
	private final String	loc;
	private final String	desc;
	private final String	icon;
	private final String	penaltyIcon;
	private final String	guideIcon;
	private final String	guardian;
	// Deterministic
	private boolean			castle		= false;
	private boolean			hideout		= false;
	private int				lease		= 0;
	private int				grade		= 0;
	private boolean			territory	= false;
	private boolean			fortress	= false;
	private boolean			border		= false;
	// Experimental
	private int				barType		= 0;

	/**
	 * Creates a castle/clan hall/fortress entity.
	 * @param element index in file
	 * @param tag unknown
	 * @param id entity ID
	 * @param name entity name
	 * @param loc nearest town
	 * @param desc entity description
	 * @param icon territory icon
	 * @param penaltyIcon territory icon under penalty
	 * @param guideIcon territory icon in the guide window
	 * @param guardian territory guardian
	 */
	public ClanBase(int element, int tag, int id, String name, String loc, String desc, String icon, String penaltyIcon, String guideIcon, String guardian)
	{
		this.element = element;
		this.tag = tag;
		this.id = id;
		this.name = name;
		this.loc = loc;
		this.desc = desc;
		this.icon = icon;
		this.penaltyIcon = penaltyIcon;
		this.guideIcon = guideIcon;
		this.guardian = guardian;
	}

	/**
	 * @return whether this entity is a castle
	 */
	public final boolean isCastle()
	{
		return castle;
	}

	/**
	 * @param castle the castle attribute to set
	 */
	public final void setCastle(boolean castle)
	{
		this.castle = castle;
	}

	/**
	 * @return whether this entity is a hideout
	 */
	public final boolean isHideout()
	{
		return hideout;
	}

	/**
	 * @param hideout the hideout attribute to set
	 */
	public final void setHideout(boolean hideout)
	{
		this.hideout = hideout;
	}

	/**
	 * @return the lease cost
	 */
	public final int getLease()
	{
		return lease;
	}

	/**
	 * @param lease the lease cost to set
	 */
	public final void setLease(int lease)
	{
		this.lease = lease;
	}

	/**
	 * @return the hideout grade
	 */
	public final int getGrade()
	{
		return grade;
	}

	/**
	 * @param grade the hideout grade to set
	 */
	public final void setGrade(int grade)
	{
		this.grade = grade;
	}

	/**
	 * @return whether this entry is a territory
	 */
	public boolean isTerritory()
	{
		return territory;
	}

	/**
	 * @param territory the territory attribute to set
	 */
	public void setTerritory(boolean territory)
	{
		this.territory = territory;
	}

	/**
	 * @return whether this entity is a fortress
	 */
	public final boolean isFortress()
	{
		return fortress;
	}

	/**
	 * @param fortress the fortress attribute to set
	 */
	public final void setFortress(boolean fortress)
	{
		this.fortress = fortress;
	}

	/**
	 * @return the border status of a fortress
	 */
	public boolean isBorder()
	{
		return border;
	}

	/**
	 * @param border the border status to set
	 */
	public void setBorder(boolean border)
	{
		this.border = border;
	}

	/**
	 * @return the fortress type
	 */
	public final int getBarType()
	{
		return barType;
	}

	/**
	 * @param barType the fortress type to set
	 */
	public final void setBarType(int barType)
	{
		this.barType = barType;
	}

	/**
	 * @return the element number
	 */
	public final int getElement()
	{
		return element;
	}

	/**
	 * @return unknown
	 */
	public final int getTag()
	{
		return tag;
	}

	/**
	 * @return the entity ID
	 */
	public final int getId()
	{
		return id;
	}

	/**
	 * @return the entity name
	 */
	public final String getName()
	{
		return name;
	}

	/**
	 * @return the location
	 */
	public final String getLoc()
	{
		return loc;
	}

	/**
	 * @return the description
	 */
	public final String getDesc()
	{
		return desc;
	}

	/**
	 * @return the territory icon
	 */
	public final String getIcon()
	{
		return icon;
	}

	/**
	 * @return the territory icon under penalty
	 */
	public final String getPenaltyIcon()
	{
		return penaltyIcon;
	}

	/**
	 * @return the territory icon in the guide window
	 */
	public final String getGuideIcon()
	{
		return guideIcon;
	}

	/**
	 * @return the territory guardian
	 */
	public final String getGuardian()
	{
		return guardian;
	}

	/* (non-Javadoc)
	 * @see com.l2cdp.entity.IAnalysis#deterministicAnalysis()
	 */
	@Override
	public void deterministicAnalysis()
	{
		if (id > 100)
		{
			fortress = true;
			border = desc.contains("between") || desc.contains("border");
		}
		else if (id > 80)
			territory = true;
		else if (id > 20)
			hideout = true;
		else if (id > 0)
			castle = true;
		if (hideout)
		{
			if (desc.contains("located"))
			{
				if (loc.contains("ludi") || loc.contains("uttg"))
				{
					lease = 500000;
					grade = 2;
				}
				else if (loc.contains("ion"))
				{
					lease = 200000;
					grade = 1;
				}
				else
				{
					lease = 1000000;
					grade = 3;
				}
			}
			else if (desc.contains("ontestable"))
			{
				if (name.contains("ortres") && name.contains("ead"))
					grade = 4;
				else
					grade = 3;
			}
		}
	}

	/* (non-Javadoc)
	 * @see com.l2cdp.entity.IAnalysis#experimentalAnalysis()
	 */
	@Override
	public void experimentalAnalysis()
	{
		switch (id)
		{
			case 102:
			case 104:
			case 107:
			case 109:
			case 110:
			case 112:
			case 113:
			case 116:
			case 117:
			case 118:
				barType = 1;
		}
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString()
	{
		return getName() + ": " + getDesc();
	}
}
